package com.soft.service;

import com.soft.dao.JobChangeDaoImpl;
import com.soft.pojo.JobChange;
import com.soft.utils.Result;

import java.util.ArrayList;

/**
 * @author ruoxi
 * @create 2021-12-27 10:12
 */
public class JobChangeService {
    private JobChangeDaoImpl jobChangeDao = new JobChangeDaoImpl();

    public int findJobChangeCount() {
        return jobChangeDao.selectByAll().size();
    }

    public ArrayList<JobChange> findJobChangeByPage(int currentPage, int currentCount) {
        return (ArrayList<JobChange>) jobChangeDao.selectJobChangeByPage(currentPage, currentCount);
    }

    public JobChange findJobChangeById(int id){
        return jobChangeDao.selectJobChangeById(id);
    }

    public Result jobChangePass(int eno, String afterjob) {
        int line = jobChangeDao.updateJobChangePassStateByEno(eno, afterjob);
        if (line>1) {
            return Result.me().setMsg("已通过");
        }
        return Result.me(false).setMsg("通过失败");
    }

    public Result jobChangeFail(int eno){
        int line = jobChangeDao.updateJobChangeFailStateByEno(eno);
        if (line>0) {
            return Result.me().setMsg("已拒绝");
        }
        return Result.me(false).setMsg("系统故障，处理失败");
    }
}
